package com.kexinde.wjifen.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 * 
 * @author wei
 * 
 * 商品
 *
 */
@Entity
public class Gift {

	private long id;  // 标识（主键）
	private String shopProfile;  // 商品简介
	private String name;  // 商品名
	private int needPoint;  // 所需积分
	private String path;  // 图片路径
	private Shop shop;  // 商店编号
	private List<ExchangeLog> exchangeLogs = new ArrayList<ExchangeLog>();  //  兑换记录
	private int amount;  // 兑换次数
	
	public Gift(){}

	@Id
	@GeneratedValue
	public long getId() {
		return id;
	}
 
	public void setId(long id) {
		this.id = id;
	}

	public String getShopProfile() {
		return shopProfile;
	}

	public void setShopProfile(String shopProfile) {
		this.shopProfile = shopProfile;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getNeedPoint() {
		return needPoint;
	}

	public void setNeedPoint(int needPoint) {
		this.needPoint = needPoint;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@ManyToOne(cascade=CascadeType.ALL)
	public Shop getShop() {
		return shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
	}

	@OneToMany(mappedBy="gift",cascade=CascadeType.ALL)
	public List<ExchangeLog> getExchangeLogs() {
		return exchangeLogs;
	}

	public void setExchangeLogs(List<ExchangeLog> exchangeLogs) {
		this.exchangeLogs = exchangeLogs;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}

	@Override
	public String toString() {
		return "Gift [id=" + id + ", shopProfile=" + shopProfile + ", name="
				+ name + ", needPoint=" + needPoint + ", path=" + path
				+ ", shop=" + shop + ", exchangeLogs=" + exchangeLogs
				+ ", amount=" + amount + "]";
	}
	
}
